import scrapy
from scrapy import Request
from gerapy_pyppeteer import PyppeteerRequest

class BookSpider(scrapy.Spider):
    name = 'book'
    allowed_domains = ['dynamic5.scrape.center']

    base_url = 'http://dynamic5.scrape.center/page/{page}'
    max_page=10

    def start_requests(self):
        for page in range(1,self.max_page+1):

            url=self.base_url.format(page=page)
            #yield Request(url,callback=self.parse_index)
            yield PyppeteerRequest(url,callback=self.parse_index,wait_for='.item .name')

    def parse_index(self, response):
        print(response.text)
